﻿using System;
using AopAlliance.Intercept;
using System.Windows.Forms;

namespace Landpy.CruiseControlNet.Infrastructure.Aop.Interceptor
{
    public class ExceptionMessageBoxInterceptor : IMethodInterceptor
    {
        public object Invoke(IMethodInvocation invocation)
        {
            object returnValue = null;
            try
            {
                returnValue = invocation.Proceed();
            }
            catch (Exception exception)
            {
                MessageBox.Show(String.Format(@"{0} Please use the analyzer to check log-file.log file which is in the application root folder", exception.Message), @"Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
            return returnValue;
        }
    }
}
